<?php

namespace app\common\model\xiluhouse;

use think\Model;

class InsidePages extends Model
{

    // 表名
    protected $name = 'xiluhouse_inside_pages';

    // 自动写入时间戳字段
    protected $autoWriteTimestamp = 'int';

    // 定义时间戳字段名
    protected $createTime = 'createtime';
    protected $updateTime = false;
    protected $deleteTime = false;

    // 追加属性
    protected $append = [
        'is_need_param_text',
        'is_need_login_text',
    ];

    public function getIsNeedParamList()
    {
        return ['1' => __('Is_need_param 1'), '2' => __('Is_need_param 2')];
    }

    public function getIsNeedLoginList()
    {
        return ['1' => __('Is_need_login 1'), '2' => __('Is_need_login 2')];
    }

    public function getIsNeedParamTextAttr($value, $data)
    {
        $value = $value ? $value : (isset($data['is_need_param']) ? $data['is_need_param'] : '');
        $list = $this->getIsNeedParamList();
        return isset($list[$value]) ? $list[$value] : '';
    }

    public function getIsNeedLoginTextAttr($value, $data)
    {
        $value = $value ? $value : (isset($data['is_need_login']) ? $data['is_need_login'] : '');
        $list = $this->getIsNeedLoginList();
        return isset($list[$value]) ? $list[$value] : '';
    }

}
